<?php
/**
 * Created by PhpStorm.
 * User: LYQ
 * Date: 2019/8/17
 * Time: 16:44
 */

namespace app\admin\controller;

use think\Controller;
use app\index\model\BaseModel;
use think\Db;

class Index extends Controller
{
    public function index()
    {
        $this->view->assign([

        ]);
        return $this->fetch('index');
    }
    public function img_table()
    {
        $this->view->assign([
            'rowsLunboImg'=> BaseModel::selectAll("lunboImg"),
            'rowsPaoMaDengImg'=> BaseModel::selectAll("paomadengImg"),
            'rowsInformationImg'=> BaseModel::selectAll("informationImg")
        ]);
        return $this->fetch('img_table');
    }
    public function project_table(){
        $projectId = I("projectId");
        $projectText = "";
        switch ($projectId){
            case 1:
                $article = BaseModel::select('article','project_id',$projectId);
                $projectText = "信息快讯";
                break;
            case 2:
                $article = BaseModel::select('article','project_id',$projectId);
                $projectText = "校企合作";
                break;
            case 3:
                $article = BaseModel::select('article','project_id',$projectId);
                $projectText = "学生工作";
                break;
            case 4:
                $article = BaseModel::select('article','project_id',$projectId);
                $projectText = "教师风采";
                break;
            case 5:
                $article = BaseModel::select('article','project_id',$projectId);
                $projectText = "信息通知";
                break;
        }
        $this->view->assign([
            'projectId'=>$projectId,
            'article'=>$article,
            'projectText'=>$projectText
        ]);
        return $this->fetch('project_table');
    }
    public function menu_table(){
        $rowsMenu = BaseModel::selectAll('menu');
        $rowsTag = Db::query("SELECT tag.name, tag.menu_id, menu.id,menu.name as 'name1' FROM tag JOIN menu ON tag.menu_id = menu.id ORDER BY tag.id");
        $this->view->assign([
            'rowsMenu'=>$rowsMenu,
            'rowsTag'=>$rowsTag
        ]);
        return $this->fetch('menu_table');
    }
    public function add(){

        $addId = I("addId");
        $addTitle="";
        switch ($addId){
            case 1:
                $addTitle = "信息快讯";
                break;
            case 2:
                $addTitle = "校企合作";
                break;
            case 3:
                $addTitle = "学生工作";
                break;
            case 4:
                $addTitle = "教师风采";
                break;
            case 5:
                $addTitle = "信息通知";
                break;
        }


        //查找所有专栏
        $rowsColumn = BaseModel::selectAll('project');

        //查找所有菜单
        $rowsMenu = BaseModel::selectAll('menu');

        //查找所有二级菜单
        $rowsTag = BaseModel::selectAll('tag');

         $this->view->assign([
             'addTitle'=>$addTitle,
            'rowsColumn'=>$rowsColumn,
            'rowsMenu'=>$rowsMenu,
            'rowsTag'=>$rowsTag
        ]);
        return $this->fetch('add');
    }
}